package com.colbert.jknife.util;

import android.app.Activity;
import android.app.Dialog;
import android.app.Fragment;
import android.view.View;

public class ViewFinder {

    public static View findViewById(Object parentView, Object target, int id) {
        if (parentView != null && parentView instanceof View) {
            return ((View) parentView).findViewById(id);
        } else if (target instanceof Activity) {
            return ((Activity) target).findViewById(id);
        } else if (target instanceof Dialog) {
            return ((Dialog) target).findViewById(id);
        } else if (target instanceof Fragment) {
            return ((Fragment) target).getView().findViewById(id);
        }
        return null;
    }
}
